package com.cl.utility.constant;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author liddhappy
 * @description
 * @createTime 2022/11/12 11:13
 */
@Data
@ApiModel(value = "response Message Info")
@NoArgsConstructor
public class Message {
    @ApiModelProperty(value = "type :SUCCESS, WARN, FAILED, ERROR, INFO;")
    private Type type;
    @ApiModelProperty(value = "type :SUCCESS(200), WARN(401,402), FAILED, ERROR(500), INFO;")
    private String code;
    private String text;

    public enum Type {
        SUCCESS, WARN, FAILED, ERROR, INFO
    }

    public Message(Type type, String code, String text) {
        this.type = type;
        this.code = code;
        this.text = text;
    }

    public Message(Type type, String text) {
        this.type = type;
        this.text = text;
    }

    public static Message Success() {
        return new Message(Type.SUCCESS, "200", "success");
    }

    public static Message Success(String text) {
        return new Message(Type.SUCCESS, "200", text);
    }

    public static Message WARN(String text) {
        return new Message(Type.WARN, text);
    }

    public static Message ERROR(String text) {
        return new Message(Type.ERROR, text);
    }

    public static Message INFO(String text) {
        return new Message(Type.INFO, text);
    }

    public static Message Failed() {
        return new Message(Type.FAILED, "500", "failed");
    }
}
